<%@page contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1 
	response.setHeader("Pragma", "no-cache"); //HTTP 1.0 
	response.setDateHeader("Expires", 0);

	String skin = "default";
	String imgPath = request.getContextPath() + "/resources/skins/"
			+ skin + "/images";
	String login_code=request.getParameter("login_code");
	if(login_code==null)login_code="";
	String password=request.getParameter("password");
	if(password==null)password="";
	
	String a = request.getParameter("a");
	if("y".equals(a)){
		login_code=request.getParameter("l");
		password=request.getParameter("p");
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>企助之星登陆</title>
		<style type="text/css">
		<!--
		body {margin: 0px; background:url(<%=imgPath%>/index/f.gif) repeat; font-size:12px;}
		input,form{ margin:0 auto;}
		.left{ float:left;}
		.right{ float:right;}
		.LoginBox{ margin:140px auto 0 auto; width:320px; height:111px; background:url(<%=imgPath%>/index/login_bg.png) no-repeat; padding:70px 0; color:#fff; position:relative;}
		.LoginInput{ margin-left:40px;height:86px;}
		.login_input{height:21px; width:147px; line-height:21px; background:url(<%=imgPath%>/index/login_input.gif) no-repeat; border:none; padding-left:5px; margin-top:5px;}
		.yanzheng{ width:57px; height:21px;  line-height:21px;  background:url(<%=imgPath%>/index/yanzheng.gif) no-repeat; border:none;padding-left:5px; }
		.LoginButtom{ margin-top:40px; text-align:center;}
		.LoginButtom img{ margin: 0 10px;}
		.LoginBox span{width:147px;	height:175px;	display:block;	background:url(<%=imgPath%>/index/login_icon.png) no-repeat;position:absolute;left: 282px;	top: 79px;}
		
		
		-->
		</style>
		<script type="text/javascript" src="<%=path%>/resources/js/jquery-1.4.4.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/resources/js/jquery.form.js"></script>
		<script type="text/javascript">
			var login = function(){
				var options = {
					type: 'POST',
					async: false,
					dataType: 'content-type',
					success: function(msg) {
						if(msg=="codenull"){
							alert("验证码不得为空");
						}else if(msg=="codedif"){
							alert("验证码不正确，请重新出入");
							$("veryCode").attr("value","");
						}else if(msg=="success"){
							document.location="<%=path%>/sys/get/index";
						}else{
							alert("用户名或密码错误！");
						}
					}
				}
				//提交form
				$('#loginfrm').ajaxSubmit(options);
				changeImg();
			}
			var keyup = function(e){
				if(e.keyCode == 13){
					login();
				}
			}
			function changeImg(){      
				var imgSrc = $("#imgObj");
				var src = imgSrc.attr("src");  
				imgSrc.attr("src",chgUrl(src));     
			}     
			//时间戳     
			//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳     
			function chgUrl(url){         
				var timestamp = (new Date()).valueOf();         
				urlurl = url.substring(0,17);         
				if((url.indexOf("&")>=0)){             
					urlurl = url + "&tamp=" + timestamp;         
				}else{             
					urlurl = url + "?timestamp=" + timestamp;         
				}         
				return urlurl;     
			} 
			
		</script>
	</head>

<body onkeyup="keyup(event)">
<form action="<%=path%>/sys/login" name="loginfrm" id="loginfrm"
	method="post">
	<input type="hidden" name="a" value="<%=a %>"/>
<div class="LoginBox">
	<div class="LoginInput">
	      用户名：<input type="text" name="login_code" id="login_code" value="<%=login_code %>" class="login_input" /><br />
	      密&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="password" name="password" class="login_input"  value="<%=password %>"/><br />
	      <div style="margin-top:5px">
	      	<bdo style="float:left;margin-top: 6px">验证码：</bdo>
	      	<input type="text" style="float: left" name="veryCode" id="veryCode" class="yanzheng"/>
	      	<img src="<%=path %>/sys/getImg" id="imgObj" style="float: left;line-height: 21px;height:21px" width="66" border="0" />
	      	<a style="float:left;margin: 6px 0 0 5px;text-decoration: none" href="javascript:changeImg()" >换一张</a>
	      </div>
  		  <div style="clear: both;"></div>
    </div>
    <div class="LoginButtom" >
		<a href="#" onclick="login()"><img src="<%=imgPath%>/index/denglu.gif" width="66" height="23" border="0" /></a>
	</div>
    <span></span>
</div>
</form>
<script> 
	document.getElementById("login_code").buler;
	<%
	if("y".equals(a)){
	%>
		login();
	<%
	}
	%>
</script>
</body>
</html>